package charCount;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.jar.JarException;

public class CharCount {
	public static void main(String[] args) throws IOException{

		Char[] c = new Char[26];
		String[] alpha = {"a","b","c","d","e","f","g","h","i","j","k","l",
						"m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		
		File file = new File("Jimmy Neutron.txt");
		InputStream in = new FileInputStream(file);
		InputStreamReader reader = new InputStreamReader(in);
		
		int data,i=0;
		StringBuffer sb = new StringBuffer();
		while((data = reader.read()) != -1){
			System.out.print((char)data);
			sb.append((char)data);
			i++;
		}
		
		String kalimat = sb.toString();
		int[] count = new int[i];
		int a = 0;
		for(int k=0; k<26 ; k++){
			for(int j=0 ; j<kalimat.length() ; j++){
				String b = Character.toString(kalimat.charAt(j));
				
				if(b.equalsIgnoreCase(alpha[k])){
					a = count[k]++;
					
//					c[0].setCh("a");
					//c[k].setCount(count[k]++);
					c[k] = new Char(b,a);
				}
//				else{
//					c[k] = new Char(b,0);
//				}
			}
		}
		
		//System.out.println(c[0].getCh());
		
		for(int l=0 ; l<26 ; l++){
			System.out.println(c[l].getCh() + " = " + c[l].getCount());
		}
		
		
		reader.close();
		in.close();
		
	}
	
	
	};
